/*
* 存储storage
* */
const setStore = (name, content) => {
  if (!name) return false
  if (typeof content !== 'string') {
    content = JSON.stringify(content)
  }
  try {
    window.sessionStorage.setItem(name, content)
  } catch (oException) {
    if (oException.name === 'QuotaExceededError') {
      this.$message({
        message: '超出本地存储限额！',
        type: 'warning',
        customClass: 'zZindex',
        duration: 5000
      })
    }
  }
}

/*
 * 获取storage
 * */
const getStore = (name) => {
  if (!name) return false
  return window.sessionStorage.getItem(name)
}

/*
* 刪除storage
* */
const removeStore = (name) => {
  if (!name) return false
  window.sessionStorage.removeItem(name)
}

/*
* 清空storage
* */
const clearStore = () => {
  window.sessionStorage.clear()
}

export {
  setStore,
  getStore,
  removeStore,
  clearStore
}
